using System;


using tiger.dotnet;
using System.Reflection;
using Manager_Namespace;
using Employees_Namespace;
using com.eibus.bdf;
using TigerNET;
using com.eibus.xml.nom;
using com.eibus.connector.nom;


namespace TigerRuntime
{
	/// <summary>
	/// Summary description for TigerRuntime.
	/// </summary>
	public class TigerRuntime
	{
		public TigerRuntime()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		public static int lastCount =11;
		
		[STAThread]
		static void Main(string[] args)
		{
			 string[] methodNames ={"shortMethod","booleanMethod","floatMethod","intMethod","longMethod","byteMethod","charMethod","stringMethod","doubleMethod"};
			 string[] fieldNames ={"shortParam","booleanParam","floatParam","intParam","longParam","byteParam","charParam","stringParam","doubleParam"};
			
			
			try
			{
				for (int i =0; i <100; i++)
				{
					int ctr =0;
					for (ctr =0; ctr < 9; ctr++)
					{
						testConnctorGetLDAPObject();
						testPrimitiveInstance(methodNames[ctr]);
						instanceMethodsWithObjects();
						testPrimitiveStatic(methodNames[ctr]);
						staticMethodsWithObjects();
						getEmployee(); 
						getEmployees();
						insertEmployee();
						updateEmployee();
						deleteEmployee();
						testReturnArraysWithInstance(methodNames[ctr]);
						testReturnArraysWithStatic(methodNames[ctr]);
						testPrimitiveArgsReturnArraysInstance();
						testPrimitiveArgsReturnArraysStatic();
						testPassingAndReturningArrays();
						setAndGetPrimitiveField(fieldNames[ctr]);
						setAndGetPrimitveStaticFields(fieldNames[ctr]);
						testMixedTypes();
						testParameterConstWithIntArgs();
						testParameterConstWithStringArgs();
						testParameterConstructors();
						testDifferentMethods();
					}
				}
				
			}
			catch(Exception ex)
			{
				Console.WriteLine(ex.ToString());
			}
		}
	
		


		public static bool checkForException(string methodName,string originalValue,string modifiedValue)
		{
			try
			{
				if (originalValue.ToLower() != modifiedValue.ToLower())
				{
					
					Console.WriteLine("Values are different");
					Console.WriteLine("New Value " +modifiedValue);
					Console.WriteLine("Old Value " +originalValue);
					throw (new Exception("TIGER RunTime failed for the Method  "+
						methodName +">>> Exepected Value is :- "+originalValue +
						">>> Response Received Value is :- " +modifiedValue)	);
				}
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}
	
		
		public static bool testConnctorGetLDAPObject()
		{
			int request =0, response = 0;
			Connector connector		 = null;
			string dn ="cn=SYSTEM,cn=organizational users,o=system,cn=cordys,o=vanenburg.com";
			string ldapNamespace ="http://schemas.cordys.com/1.0/ldap";
			int users	=	0;
		
			try
			{
				connector = Connector.getInstance("Tiger Client");
				if (! connector.isOpen())
					connector.open();
				request = connector.createSOAPMethod(ldapNamespace,"GetLDAPObject");
				Node.createTextElement("dn",dn,request);
				response  = connector.sendAndWait(Node.getParent(request));
				users = Find.firstMatch( response , "?<authenticationuser>");
				if (users == 0)
					throw new Exception("Connector - GetLDAPObject Returned Invalid Response");
				Node.delete(users);
				users = 0 ;
			}
			catch(Exception ex)
			{
				throw new Exception("Connector -GetLDAPObject Returned Invalid " +ex.ToString());
			}
			finally
			{
				Node.delete(Node.getRoot(request));
				Node.delete(Node.getRoot(response));
				connector.Destroy();
				connector =null;
			}
			return true;
		}


		public static  bool testPrimitiveInstance(string methodName)
		{
			try
			{
				PrimitiveTypeMethodsAndFields pType = new PrimitiveTypeMethodsAndFields();	
				switch(methodName)
				{
					case "intMethod":
					{
						int intVal =pType.intMethod(10000);
						checkForException("testPrimitiveInstance-intMethod",intVal.ToString(),"10000");
						break;
					}
					case "longMethod":
					{
						long longVal =pType.longMethod(10000);
						checkForException("testPrimitiveInstance-longMethod",longVal.ToString(),"10000");
						break;
					}
					case "byteMethod":
					{
						sbyte byteVal= pType.byteMethod(1);
						checkForException("testPrimitiveInstance-byteMethod",byteVal.ToString(),"1");
						break;
					}

					case "charMethod":
					{
						char charVal = pType.charMethod('A');
						checkForException("testPrimitiveInstance-charMethod",charVal.ToString(),"A");
						break;
					}
					case "stringMethod":
					{
						string strVal = pType.stringMethod("Cordys");
						checkForException("testPrimitiveInstance-stringMethod",strVal,"Cordys");
						break;	
					}
					case "doubleMethod":
					{
						double dblVal = pType.doubleMethod(1234.56);
						checkForException("testPrimitiveInstance-doubleMethod",dblVal.ToString(),"1234.56");
						break;
					}

					case "floatMethod":
					{
						float fltVal = pType.floatMethod(1224.5f);
						checkForException("testPrimitiveInstance-floatMethod",fltVal.ToString(),"1224.5");
						break;
					}
					case "booleanMethod":
					{
						bool blVal = pType.booleanMethod(true);
						checkForException("testPrimitiveInstance-booleanMethod",blVal.ToString(),"true");
						break;
					}
					case "shortMethod":
					{
						short shVal = pType.shortMethod(123);
						checkForException("testPrimitiveInstance-shortMethod",shVal.ToString(),"123"); 
						break;
					}
					default :
					{
						throw (new Exception("Invalid Arguments ,in testPrimitiveInstance"));
					}
				}
				pType.Destroy();
				pType=null;
				return true;
			}
			catch(Exception ex)
			{
				throw ex;
			}
		}
		
		public static bool instanceMethodsWithObjects()
		{
			PrimitiveTypeMethodsAndFields pType = new PrimitiveTypeMethodsAndFields();	

			java.lang.Object obj =new java.lang.Object();
			java.lang.Object objectVal =pType.objectMethod(obj);
			checkForException("instanceMethodsWithObjects-objectMethod",objectVal.toString(),obj.toString());
			obj.Destroy();
			objectVal.Destroy();
			pType.Destroy();
			pType=null;
			return true;
		}

		

		public static  bool testPrimitiveStatic(string methodName)
		{
			try
			{
				
				switch(methodName)
				{
					case "intMethod":
					{
						int intVal =PrimitiveTypeMethodsAndFields.intStaticMethod(10000);
						checkForException("testPrimitiveStatic-intMethod",intVal.ToString(),"10000");
						break;
					}
					case "longMethod":
					{
						long longVal =PrimitiveTypeMethodsAndFields.longStaticMethod(10000);
						checkForException("testPrimitiveStatic-longMethod",longVal.ToString(),"10000");
						break;
					}
					case "byteMethod":
					{
						sbyte byteVal= PrimitiveTypeMethodsAndFields.byteStaticMethod(1);
						checkForException("testPrimitiveStatic-byteMethod",byteVal.ToString(),"1");
						break;
					}
					case "charMethod":
					{
						char charVal = PrimitiveTypeMethodsAndFields.charStaticMethod('A');
						checkForException("testPrimitiveStatic-charMethod",charVal.ToString(),"A");
						break;
					}
					case "stringMethod":
					{
						string strVal = PrimitiveTypeMethodsAndFields.stringStaticMethod("Cordys");
						checkForException("testPrimitiveStatic-stringMethod",strVal,"Cordys");
						break;	
					}
					case "doubleMethod":
					{
						double dblVal = PrimitiveTypeMethodsAndFields.doubleStaticMethod(1234.56);
						checkForException("testPrimitiveStatic-doubleMethod",dblVal.ToString(),"1234.56");
						break;
					}
					case "floatMethod":
					{
						float fltVal = PrimitiveTypeMethodsAndFields.floatStaticMethod(1224.5f);
						checkForException("testPrimitiveStatic-floatMethod",fltVal.ToString(),"1224.5");
						break;
					}
					case "booleanMethod":
					{
						bool blVal = PrimitiveTypeMethodsAndFields.booleanStaticMethod(true);
						checkForException("testPrimitiveStatic-booleanMethod",blVal.ToString(),"true");
						break;
					}
					case "shortMethod":
					{
						short shVal = PrimitiveTypeMethodsAndFields.shortStaticMethod(123);
						checkForException("testPrimitiveStatic-shortMethod",shVal.ToString(),"123"); 
						break;
					}
					default :
					{
						throw (new Exception("Invalid Arguments ,in testPrimitiveStatic"));
					}
						
				}
				return true;
			}
			catch(Exception ex)
			{
				throw ex;
			}
		}
		
		
		public static bool staticMethodsWithObjects()
		{
			java.lang.Object obj =new java.lang.Object();
			java.lang.Object objectVal =PrimitiveTypeMethodsAndFields.objectStaticMethod(obj);
			checkForException("staticMethodsWithObjects-objectMethod",objectVal.toString(),obj.toString());
			obj.Destroy();
			obj=null;
			objectVal.Destroy();
			objectVal=null;
			return true;
		}

		public  static  bool getEmployee()
		{
			try
			{
				Manager manager		=	new Manager();
				Employees employee	=	manager.GetEmployee(1);
				int empID			=	employee.getEmployeeID();
				checkForException("getEmployee",empID.ToString(),"1");
				employee.Destroy();
				manager.Destroy();
				employee	=	null;
				manager		=	null;
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}
	
		

		public static  bool  getEmployees()
		{
			try
			{
				lastCount =0;
				Manager manager =new Manager();
				com.eibus.bdf.Iterator iterator  = manager.GetEmployees(1,400000);
				if (iterator != null)
				{
					while(iterator.hasMoreElements())
					{
						object objet			=	iterator.nextElement();
						Employees  employee		=	Employees.TypeCast(objet);
						int empID = employee.getEmployeeID();
						lastCount = empID;
						employee.getFirstName();
						employee.Destroy();
						employee=null;
					}
					iterator.Destroy();
				}
				
				manager.Destroy();
				iterator =null;
				manager=null;
				
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}

		public static bool insertEmployee()
		{
			try
			{
				Manager manager =new Manager();
				object emppObject = manager.createComplexType(Employees.NAMESPACE,"Employees");
				Employees emp = Employees.TypeCast(emppObject);
				emp.setAddress("Hyderabad");
				emp.setFirstName("Philips");
				emp.setLastName("Peter");
				emp.setTitle("Software Engineer");
				manager.synchronize();
				emp.Destroy();
				manager.Destroy();
				manager=null;
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}


		
		public static bool updateEmployee()
		{
			int empIdTobeUpdated =lastCount;
			try
			{
				getEmployees();
				empIdTobeUpdated	=	lastCount;
				Manager manager		=	new Manager();
				Employees employee	=	manager.GetEmployee(empIdTobeUpdated);
				employee.setFirstName("Rosman");
				employee.setLastName("george");
				manager.synchronize();
				employee.Destroy();

				Employees employees	=	manager.GetEmployee(empIdTobeUpdated);
				string name = employees.getFirstName();
				checkForException("updateEmployee","Rosman",name);
				employees.Destroy();
				manager.Destroy();

			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}
		
		public static bool deleteEmployee()
		{
			int empIdTobeDeleted  = 0;
			try
			{
				getEmployees();
				empIdTobeDeleted	=	lastCount;
				Manager manager		=	new Manager();
				Employees employee	=	manager.GetEmployee(empIdTobeDeleted);
				ComplexType cType	=	ComplexType.TypeCast(employee.THIS);
				cType.THIS.setClassName("com.eibus.bdf.ComplexType");
				manager.markDeleted(cType);
				manager.synchronize();
				employee.Destroy();
				manager.Destroy();
			
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}

	
	

		public static bool testReturnArraysWithInstance(string methodName)
		{
			try
			{
				
				PrimitiveParameterAndArrayReturnMethods pType = new PrimitiveParameterAndArrayReturnMethods();
			
				switch(methodName)
				{
					case "intMethod":
					{
						int[] intVal =pType.intMethod(100);
						checkForException("testReturnArraysWithInstance-intMethod",intVal[0].ToString(),"100");
						intVal =null;
						break;
					}
					case "longMethod":
					{
						long[] longVal =pType.longMethod(100);
						longVal =null;
						break;
					}
					case "byteMethod":
					{
						sbyte[] byteVal= pType.byteMethod(1);
						checkForException("testReturnArraysWithInstance-byteMethod",byteVal[0].ToString(),"1");
						byteVal =null;
						break;
					}
					case "stringMethod":
					{
						string[] strVal = pType.stringMethod("Cordys");
						checkForException("testReturnArraysWithInstance-stringMethod",strVal[0],"Cordys");
						strVal =null;
						break;
					}
					case "doubleMethod":
					{
						double[] dblVal = pType.doubleMethod(1234.56);
						checkForException("testReturnArraysWithInstance-doubleMethod",dblVal[0].ToString(),"1234.56");
						dblVal =null;
						break;
					}
					case "floatMethod" :
					{
						float[] fltVal = pType.floatMethod(1224.5f);
						checkForException("testReturnArraysWithInstance-floatMethod",fltVal[0].ToString(),"1224.5");
						fltVal =null;
						break;
					}
					case "booleanMethod":
					{
						bool[] blVal = pType.booleanMethod(true);
						checkForException("testReturnArraysWithInstance-booleanMethod",blVal[0].ToString(),"true");
						blVal =null;
						break;
					}
					case "shortMethod":
					{
						short[] shVal = pType.shortMethod(123);
						checkForException("testReturnArraysWithInstance-shortMethod",shVal[0].ToString(),"123");  
						shVal =null; 
						break;
					}
					case "charMethod":
					{
						break;
					}
					default :
					{
						throw (new Exception("Invalid Arguments ,in testReturnArraysWithInstance"));
					}
				}

				pType.Destroy();
				pType=null;
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}



		public static bool testReturnArraysWithStatic(string methodName)
		{
			try
			{
				switch(methodName)
				{
					case "intMethod":
					{
						int[] intVal =PrimitiveParameterAndArrayReturnMethods.intStaticMethod(100);
						checkForException("testReturnArraysWithStatic-intMethod",intVal[0].ToString(),"100");
						intVal =null;
						break;
					}
					case "longMethod":
					{
						long[] longVal =PrimitiveParameterAndArrayReturnMethods.longStaticMethod(100);
						longVal =null;
						break;
					}
					case "byteMethod":
					{
						sbyte[] byteVal= PrimitiveParameterAndArrayReturnMethods.bytesStaticMethod(1);
						checkForException("testReturnArraysWithStatic-byteMethod",byteVal[0].ToString(),"1");
						byteVal =null;
						break;
					}
					case "stringMethod":
					{
						string[] strVal = PrimitiveParameterAndArrayReturnMethods.stringStaticMethod("Cordys");
						checkForException("testReturnArraysWithStatic-stringMethod",strVal[0],"Cordys");
						strVal =null;
						break;
					}
					case "doubleMethod":
					{
						double[] dblVal = PrimitiveParameterAndArrayReturnMethods.doubleStaticMethod(1234.56);
						checkForException("testReturnArraysWithStatic-doubleMethod",dblVal[0].ToString(),"1234.56");
						dblVal =null;
						break;
					}
					case "floatMethod":
					{
						float[] fltVal = PrimitiveParameterAndArrayReturnMethods.floatStaticMethod(1224.5f);
						checkForException("testReturnArraysWithStatic-floatMethod",fltVal[0].ToString(),"1224.5");
						fltVal =null;
						break;
					}
					case "booleanMethod":
					{
						bool[] blVal = PrimitiveParameterAndArrayReturnMethods.booleanStaticMethod(true);
						checkForException("testReturnArraysWithStatic-booleanMethod",blVal[0].ToString(),"true");
						blVal =null;
						break;
					}
					case "shortMethod":
					{
						short[] shVal = PrimitiveParameterAndArrayReturnMethods.shortStaticMethod(123);
						checkForException("testReturnArraysWithStatic-shortMethod",shVal[0].ToString(),"123");
						shVal =null;
						break;
					}
					case "charMethod":
					{
						break;
					}
					default :
					{
						throw (new Exception("Invalid Arguments ,in testReturnArraysWithStatic"));
					}
				}
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}


		public static bool testPrimitiveArgsReturnArraysInstance()
		{
			try
			{
				bool[]	boolArr	 = {true,false,false,true,false};
				short[]	shrtArr	 = {1,2,3,4,5,6,7,8,9,10};
				char[]  chrArr	 = {'a','b','c','d','e'};
				sbyte[]	btArr	 = {0,1,0,1,0};
				string[]strArr	 = {"cordys","cordys"};
				float[] fltArr  = { 1.1f,2.2f,3.3f,4.4f,5.5f};
				double[] dblArr = {1.11,2.22,3.33,4.44,5.55};
				int[] intArr    = {1000,2000,3000,4000,5000,6000,1000,2000,3000,4000,5000,6000};
				long[] lngArr	= {100000,2000000,300000,400000,500000};
			
				ArrayParameterMethodsAndFields pType = new ArrayParameterMethodsAndFields();
			
	

				int intVal =pType.intMethod(intArr);
				checkForException("testPrimitiveArgsReturnArraysInstance-intMethod",intVal.ToString(),"1000");
	
				sbyte byteVal= pType.byteMethod(btArr);
				checkForException("testPrimitiveArgsReturnArraysInstance-byteMethod",byteVal.ToString(),"0");

				char charVal = pType.charMethod(chrArr);
				checkForException("testPrimitiveArgsReturnArraysInstance-charMethod",charVal.ToString(),"a");

				string strVal = pType.stringMethod(strArr);
				checkForException("testPrimitiveArgsReturnArraysInstance-stringMethod",strVal,"cordys");

				double dblVal = pType.doubleMethod(dblArr);
				checkForException("testPrimitiveArgsReturnArraysInstance-doubleMethod",dblVal.ToString(),"1.11");
			
				float fltVal = pType.floatMethod(fltArr);
				checkForException("testPrimitiveArgsReturnArraysInstance-floatMethod",fltVal.ToString(),"1.1");
		
				bool blVal = pType.booleanMethod(boolArr);
				checkForException("testPrimitiveArgsReturnArraysInstance-booleanMethod",blVal.ToString(),"true");

				boolArr	 =  null;
				shrtArr	 = null; 
				chrArr	 = null;
				btArr	 = null;
				strArr	 = null;
				fltArr  = null;
				dblArr = null;
				intArr    = null;
				lngArr =null;

			
				pType.Destroy();
				pType=null;
			
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}


		public static bool testPrimitiveArgsReturnArraysStatic()
		{
			try
			{
				bool[]	boolArr	 = {true,false,false,true,false};
				short[]	shrtArr	 = {1,2,3,4,5,6,7,8,9,10};
				char[]  chrArr	 = {'a','b','c','d','e'};
				sbyte[]	btArr	 = {0,1,0,1,0};
				string[]strArr	 = {"cordys","cordys"};
				float[] fltArr  = { 1.1f,2.2f,3.3f,4.4f,5.5f};
				double[] dblArr = {1.11,2.22,3.33,4.44,5.55};
				int[] intArr    = {1000,2000,3000,4000,5000,6000,1000,2000,3000,4000,5000,6000};
				long[] lngArr	= {100000,2000000,300000,400000,500000};
			
			
				int intVal =ArrayParameterMethodsAndFields.intStaticMethod(intArr);
				checkForException("testPrimitiveArgsReturnArraysStatic-intMethod",intVal.ToString(),"1000");
			
		
				sbyte byteVal= ArrayParameterMethodsAndFields.byteStaticMethod(btArr);
				checkForException("testPrimitiveArgsReturnArraysStatic-byteMethod",byteVal.ToString(),"0");

				char charVal = ArrayParameterMethodsAndFields.charStaticMethod(chrArr);
				checkForException("testPrimitiveArgsReturnArraysStatic-charMethod",charVal.ToString(),"a");

				string strVal = ArrayParameterMethodsAndFields.stringStaticMethod(strArr);
				checkForException("testPrimitiveArgsReturnArraysStatic-stringMethod",strVal,"cordys");

				double dblVal = ArrayParameterMethodsAndFields.doubleStaticMethod(dblArr);
				checkForException("testPrimitiveArgsReturnArraysStatic-doubleMethod",dblVal.ToString(),"1.11");
			
				float fltVal = ArrayParameterMethodsAndFields.floatStaticMethod(fltArr);
				checkForException("testPrimitiveArgsReturnArraysStatic-floatMethod",fltVal.ToString(),"1.1");
		
				bool blVal = ArrayParameterMethodsAndFields.booleanStaticMethod(boolArr);
				checkForException("testPrimitiveArgsReturnArraysStatic-booleanMethod",blVal.ToString(),"true");

				boolArr	 =  null;
				shrtArr	 = null;
				chrArr	 = null;
				btArr	 = null;
				strArr	 = null;
				fltArr  = null;
				dblArr = null;
				intArr    = null;
				lngArr =null;
			
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}

		public static bool testPassingAndReturningArrays()
		{
			try
			{
				bool[]	boolArr	 = {true,false,false,true,false};
				short[]	shrtArr	 = {1,2,3,4,5,6,7,8,9,10};
				char[]  chrArr	 = {'a','b','c','d','e'};
				sbyte[]	btArr	 = {0,1,0,1,0};
				string[]strArr	 = {"cordys","cordys"};
				float[] fltArr  = { 1.1f,2.2f,3.3f,4.4f,5.5f};
				double[] dblArr = {1.11,2.22,3.33,4.44,5.55};
				int[] intArr    = {1000,2000,3000,4000,5000,6000,1000,2000,3000,4000,5000,6000};
				long[] lngArr	= {100000,2000000,300000,400000,500000};
			
				ArrayParamterAndReturnMethods aMtd = new ArrayParamterAndReturnMethods();
			
				int[] intVal =aMtd.intMethod(intArr);
				checkForException("testPassingAndReturningArrays-intMethod",intVal[0].ToString(),"1000");
			
			
				sbyte[] byteVal= aMtd.byteMethod(btArr);
				checkForException("testPassingAndReturningArrays-byteMethod",byteVal[0].ToString(),"0");

				string[] strVal = aMtd.stringMethod(strArr);
				checkForException("testPassingAndReturningArrays-stringMethod",strVal[0],"cordys");

				double[] dblVal = aMtd.doubleMethod(dblArr);
				checkForException("testPassingAndReturningArrays-doubleMethod",dblVal[0].ToString(),"1.11");
			
				float[] fltVal = aMtd.floatMethod(fltArr);
				checkForException("testPassingAndReturningArrays-floatMethod",fltVal[0].ToString(),"1.1");
		
				bool[] blVal = aMtd.booleanMethod(boolArr);
				checkForException("testPassingAndReturningArrays-booleanMethod",blVal[0].ToString(),"true");

				boolArr	 =  null;
				shrtArr	 = null;
				chrArr	 = null;
				btArr	 = null;
				strArr	 = null;
				fltArr  = null;
				dblArr = null;
				intArr    = null;
				lngArr =null;
				aMtd.Destroy();
				aMtd =null;
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;

		}


		public static bool setAndGetPrimitiveField(string fieldName)
		{	
			try
			{
				PrimitiveTypeMethodsAndFields pField =new PrimitiveTypeMethodsAndFields();
				switch(fieldName)
				{
					case "booleanParam":
					{
						pField.booleanParam =true;
						checkForException("setAndGetPrimitiveField-booleanParam",pField.booleanParam.ToString(),"true");
						break;
					}
					case "byteParam":
					{	
						pField.byteParam =0 ;
						checkForException("setAndGetPrimitiveField-byteParam",pField.byteParam.ToString(),"0");
						break;
					}
					case "charParam":
					{
						pField.charParam ='a';
						checkForException("setAndGetPrimitiveField-charParam",pField.charParam.ToString(),"a");
						break;
					}
					case "doubleParam":
					{
						pField.doubleParam=12244;
						checkForException("setAndGetPrimitiveField-doubleParam",pField.doubleParam.ToString(),"12244");
						break;
					}
					case "floatParam":
					{
						pField.floatParam=34.6f;
						checkForException("setAndGetPrimitiveField-floatParam",pField.floatParam.ToString(),"34.6");
						break;
					}
					case "intParam":
					{
						pField.intParam=1000;
						checkForException("setAndGetPrimitiveField-intParam",pField.intParam.ToString(),"1000");
						break;
					}
					case "longParam":
					{
						pField.longParam=5756567;
						checkForException("setAndGetPrimitiveField-longParam",pField.longParam.ToString(),"5756567");
						break;
					}
					case "objectParam":
					{
						java.lang.Object obj= new java.lang.Object();
						pField.objectParam = obj;
						java.lang.Object obj1 =pField.objectParam;
						checkForException("setAndGetPrimitiveField-objectParam",obj1.toString(),obj.toString());
						obj1.Destroy();
						obj.Destroy();
						break;
					}
					case "shortParam":
					{
						pField.shortParam =21334;
						checkForException("setAndGetPrimitiveField-shortParam",pField.shortParam.ToString(),"21334");
						break;
					}
					case "stringParam":
					{
						pField.stringParam="Cordys";
						checkForException("setAndGetPrimitiveField-stringParam",pField.stringParam.ToString(),"Cordys");
						break;
					}
				}

				pField.Destroy();
				pField =null;
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}

		

		public static bool setAndGetPrimitveStaticFields(string fieldName)
		{	
			try
			{
				switch(fieldName)
				{
					case "booleanParam":
					{
						PrimitiveTypeMethodsAndFields.booleanStaticParam =true;
						checkForException("setAndGetPrimitiveField-booleanParam",PrimitiveTypeMethodsAndFields.booleanStaticParam.ToString(),"true");
						break;
					}
					case "byteParam":
					{	
						PrimitiveTypeMethodsAndFields.byteStaticParam =0 ;
						checkForException("setAndGetPrimitiveField-byteParam",PrimitiveTypeMethodsAndFields.byteStaticParam.ToString(),"0");
						break;
					}
					case "charParam":
					{
						PrimitiveTypeMethodsAndFields.charStaticParam ='a';
						checkForException("setAndGetPrimitiveField-charParam",PrimitiveTypeMethodsAndFields.charStaticParam.ToString(),"a");
						break;
					}
					case "doubleParam":
					{
						PrimitiveTypeMethodsAndFields.doubleStaticParam=12244;
						checkForException("setAndGetPrimitiveField-doubleParam",PrimitiveTypeMethodsAndFields.doubleStaticParam.ToString(),"12244");
						break;
					}
					case "floatParam":
					{
						PrimitiveTypeMethodsAndFields.floatStaticParam=34.6f;
						checkForException("setAndGetPrimitiveField-floatParam",PrimitiveTypeMethodsAndFields.floatStaticParam.ToString(),"34.6");
						break;
					}
					case "intParam":
					{
						PrimitiveTypeMethodsAndFields.intStaticParam=1000;
						checkForException("setAndGetPrimitiveField-intParam",PrimitiveTypeMethodsAndFields.intStaticParam.ToString(),"1000");
						break;
					}
					case "longParam":
					{
						PrimitiveTypeMethodsAndFields.longStaticParam=5756567;
						checkForException("setAndGetPrimitiveField-longParam",PrimitiveTypeMethodsAndFields.longStaticParam.ToString(),"5756567");
						break;
					}
					case "objectParam":
					{
						java.lang.Object obj= new java.lang.Object();
						PrimitiveTypeMethodsAndFields.objectStaticParam = obj;
						java.lang.Object obj1 =PrimitiveTypeMethodsAndFields.objectStaticParam;
						checkForException("setAndGetPrimitiveField-objectParam",obj1.toString(),obj.toString());
						obj1.Destroy();
						obj.Destroy();
						break;
					}
					case "shortParam":
					{
						PrimitiveTypeMethodsAndFields.shortStaticParam =21334;
						checkForException("setAndGetPrimitiveField-shortParam",PrimitiveTypeMethodsAndFields.shortStaticParam.ToString(),"21334");
						break;
					}
					case "stringParam":
					{
						PrimitiveTypeMethodsAndFields.stringStaticParam="Cordys";
						checkForException("setAndGetPrimitiveField-stringParam",PrimitiveTypeMethodsAndFields.stringStaticParam.ToString(),"Cordys");
						break;
					}
				}

			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}
		
		
		public static bool testMixedTypes()
		{
			try
			{
				MixedParameterMethods mPmtd = new MixedParameterMethods();
			
				int intVal =mPmtd.mixedIntMethod(100,1000,70000);
				checkForException("testMixedTypes-mixedIntMethod",intVal.ToString(),"100");  
			
				string[]  strArr = {"Cordys","India"};
				sbyte[]   btArr  = {0,1};
				long[]    lngArr = {100004,565677};
				int[]     intArr = {12,5,6,7,8,89,99,909,0,0};
				sbyte[]	  btVal	 = mPmtd.mixedByteMethod(strArr,btArr);
				checkForException("testMixedTypes-mixedByteMethod",btVal[0].ToString(),"0");  

				long lngVal =mPmtd.mixedLongMethod(intArr,lngArr);
				checkForException("testMixedTypes-mixedLongMethod",lngVal.ToString(),"100004");  
			
				string[] strVal =mPmtd.mixedStringMethod(strArr,lngArr);
				checkForException("testMixedTypes-mixedStringMethod",strVal[0].ToString(),"Cordys");  
			
				strArr =null;
				strVal =null;
				btArr =null;
				lngArr =null;
				intArr =null;
				btVal =null;
				mPmtd.Destroy();
				mPmtd =null;
			}
			catch(Exception ex)
			{
				throw ex;
			}

			return true;
		}
		
		public static bool testParameterConstWithIntArgs()
		{
			try
			{
				
				MixedParameterMethods pCtr2 =new MixedParameterMethods(100);
				int val1 = pCtr2.getValue();
				checkForException("testParameterConstWithIntArgs",val1.ToString(),"100");
				pCtr2.Destroy();
				pCtr2 =null;

			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}

		
		public static bool testParameterConstWithStringArgs()
		{
			try
			{
				MixedParameterMethods pCtr1 =new MixedParameterMethods("Vanenburg");
		
				string name1 =pCtr1.getName();
				checkForException("testParameterConstWithStringArgs",name1,"Vanenburg");
				pCtr1.Destroy();
				pCtr1 =null;
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}

		
		public static bool testParameterConstructors()
		{
			try
			{
				MixedParameterMethods pCtr  =new MixedParameterMethods("Vanenburg",100);
		
				string name =pCtr.getName();
				checkForException("testParameterConstructors",name,"Vanenburg");

				int val = pCtr.getValue();
				checkForException("testParameterConstructors",val.ToString(),"100");
				pCtr.Destroy();
				pCtr =null;
				
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}


		public static bool testDifferentMethods()
		{
			try
			{
				PrimitiveTypeMethodsAndFields pType = new PrimitiveTypeMethodsAndFields();	
				int intVal1 =pType.intMethod(10000);
				checkForException("testDifferentMethods-intMethod",intVal1.ToString(),"10000");
				
				int intVal2 =PrimitiveTypeMethodsAndFields.intStaticMethod(10000);
				checkForException("testDifferentMethods-intMethod",intVal2.ToString(),"10000");
				
				Manager manager		=	new Manager();
				Employees employee	=	manager.GetEmployee(1);
				int empID			=	employee.getEmployeeID();
				checkForException("testDifferentMethods-getEmployee",empID.ToString(),"1");
				
				
				PrimitiveParameterAndArrayReturnMethods prType = new PrimitiveParameterAndArrayReturnMethods();
			
				int[] intVal3 =prType.intMethod(100);
				checkForException("testReturnArraysWithInstance-intMethod",intVal3[0].ToString(),"100");
				intVal3 =null;

				string[] strVal = PrimitiveParameterAndArrayReturnMethods.stringStaticMethod("Cordys");
				checkForException("testReturnArraysWithStatic-stringMethod",strVal[0],"Cordys");
				strVal =null;

				int[] intArr    = {1000,2000,3000,4000,5000,6000,1000,2000,3000,4000,5000,6000};
				int intVal4 =ArrayParameterMethodsAndFields.intStaticMethod(intArr);
				checkForException("testPrimitiveArgsReturnArraysStatic-intMethod",intVal4.ToString(),"1000");
			
				PrimitiveTypeMethodsAndFields pField =new PrimitiveTypeMethodsAndFields();
				pField.booleanParam =true;
				checkForException("setAndGetPrimitiveField-booleanParam",pField.booleanParam.ToString(),"true");
			
				pField.Destroy();
				prType.Destroy();
				prType=null;
				employee.Destroy();
				manager.Destroy();
				employee	=null;
				manager		=null;
				pType.Destroy();
				pType=null;
			}
			catch(Exception ex)
			{
				throw ex;
			}
			return true;
		}

	}

}

